home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / as11v103.zip / ASREF.MAN < prev   
Text File  |  1992-01-31  |  77KB  |  2,239 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.                                     MOTOROLA
  11.  
  12.                                     FREEWARE
  13.  
  14.                              8-BIT CROSS ASSEMBLERS
  15.  
  16.                                   USER'S MANUAL
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.                                      EDITED BY
  44.  
  45.                                    KEVIN ANDERSON
  46.  
  47.                              FIELD APPLICATIONS ENGINEER
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.                                 MODIFIED FOR REV 1.02    
  55.  
  56.                                      10/27/1989
  57.  
  58.                                          BY
  59.  
  60.                                    Bruce L. Olney
  61.  
  62.  
  63.  
  64.                            TABLE OF CONTENTS
  65.  
  66. CHAPTER 1.........................................................  1
  67.  
  68.      1.1   INTRODUCTION ..........................................  1
  69.      1.2   ASSEMBLY LANGUAGE .....................................  1
  70.      1.3   OPERATING ENVIRONMENT .................................  2
  71.      1.4   ASSEMBLER PROCESSING ..................................  2
  72.  
  73. CHAPTER 2 ........................................................  3
  74.  
  75.      2.1   INTRODUCTION ..........................................  3
  76.      2.2   SOURCE STATEMENT FORMAT ...............................  3
  77.           2.2.1   Label Field ....................................  3
  78.           2.2.2   Operation Field ................................  4
  79.           2.2.3   Operand Field ..................................  4
  80.                2.2.3.1  M6800/6801 Operand Syntax ................  5
  81.                2.2.3.2  M6800/M68HC04 Operand Syntax .............  5
  82.                2.2.3.3  M6805/M68HC05 Operand Syntax .............  5
  83.                2.2.3.4  M6809 Operand Syntax .....................  5
  84.                2.2.3.5  M68HC11 Operand Syntax ...................  6
  85.                2.2.3.6  Expressions ..............................  6
  86.                2.2.3.7  Operators ................................  7
  87.                2.2.3.8  Symbols ..................................  7
  88.                2.2.3.9  Constants ................................  7
  89.           2.2.4   Comment Field ..................................  8
  90.      2.3   ASSEMBLER OUTPUT ......................................  9
  91.  
  92. CHAPTER 3 - RUNNING THE ASSEMBLERS ...............................  10
  93.  
  94.      3.1   ASSEMBLER INVOCATION ..................................  10
  95.      3.2   ERROR MESSAGES ........................................  11
  96.  
  97. CHAPTER 4 - ASSEMBLER DIRECTIVES .................................  12
  98.  
  99.      4.1   INTRODUCTION ..........................................  12
  100.      4.2   BSZ - BLOCK STORAGE OF ZEROS ..........................  12
  101.      4.3   EQU - EQUATE SYMBOL TO A VALUE ........................  13
  102.      4.4   FCB - FORM CONSTANT BYTE ..............................  13
  103.      4.5   FCC - FORM CONSTANT CHARACTER STRING ..................  13
  104.      4.6   FDB - FROM DOUBLE BYTE CONSTANT .......................  13
  105.      4.7   FILL - FILL MEMORY ....................................  14
  106.      4.8   OPT - ASSEMBLER OUTPUT OPTIONS ........................  14
  107.      4.9   ORG - SET PROGRAM COUNTER TO ORIGIN ...................  14
  108.      4.10   PAGE - TOP OF PAGE ...................................  15
  109.      4.11   RMB - RESERVE MEMORY BYTES ...........................  15
  110.      4.12   ZMB - ZERO MEMORY BYTES ..............................  15
  111.  
  112. APPENDIX A - CHARACTER SET .......................................  16
  113.  
  114. APPENDIX B - ADDRESSING MODES ....................................  18
  115.  
  116.      B.1   M6800/M6801 ADDRESSING MODES ..........................  18
  117.      B.2   M6804/68HC04 ADDRESSING MODES .........................  19
  118.      B.3   M6805/68HC05 ADDRESSING MODES .........................  21
  119.  
  120.  
  121.  
  122.                                 i
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.                            TABLE OF CONTENTS
  131.  
  132.      B.4   M6809 ADDRESSING MODES ................................  22
  133.      B.5   M68HC11 ADDRESSING MODES ..............................  26
  134.  
  135. APPENDIX C - DIRECTIVE SUMMARY ...................................  28
  136.  
  137. APPENDIX D - ASSEMBLER LISTING FORMAT ............................  29
  138.  
  139. APPENDIX E - S-RECORD INFORMATION ................................  30
  140.  
  141.      E.1   INTRODUCTION ..........................................  30
  142.      E.2   S-RECORD CONTENT ......................................  30
  143.      E.3   S-RECORD TYPES ........................................  30
  144.      E.4   S-RECORD EXAMPLE ......................................  31
  145.  
  146.  
  147.  
  148.  
  149.  
  150.                        REVISION 1.03 NEW FEATURES
  151.  
  152.                           3/29/90 - B. L. Olney
  153.  
  154.        While using this assembler I found several things that I didn't like
  155.      about it.  Seems as though the source code was available I decided to
  156.      make a few changes so that it is easier for me to use.  The changes I    
  157.      made are listed below.  So far the assembler should be 100% compatible 
  158.      with older versions you may have.  These are only enhancements.  Where
  159.      applicable I have modified the text of this manual to document these
  160.      changes.  If you find any buggs with the new version please direct them
  161.      to me.  (801) 778-4410 or write: attn: Bruce L. Olney, IOMEGA Corp., 
  162.      1821 w. 4000 s. Bldg. 7, Roy, UT  84067.
  163.  
  164.      - Version number is now displayed at the beginning of assembly.  Version
  165.        number at this writing is 1.03.
  166.      - The lost clusters bug is fixed.
  167.      - Comments may begin on any column if prefixed with a semicolon ';'.
  168.      - Hex constants may use a trailing 'H' or 'h.'
  169.      - Octal constants may use a trailing 'Q' or 'q.'
  170.      - Binary constants may use a trailing 'B' or 'b.'
  171.      - Shift operators are now supported. '{' is shift left and '}' is right.
  172.        They work the same as the 'C' operators '<<' and '>>'.  (Operand on
  173.        left is word to be shifted.  Operand on right is number of bits to 
  174.        shift.)
  175.      - db is a synonymn for fcb.
  176.      - dw is a synonymn for fdb.
  177.      - ds is a synonymn for rmb.
  178.      - Formatting of symbol table enhanced.
  179.      - Number of errors now reported at end of assembly.
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.                                 ii
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.                                CHAPTER 1
  197.                           GENERAL INFORMATION
  198.  
  199.  
  200. 1.1   INTRODUCTION
  201.  
  202. This is the user's reference manual for the IBM-PC hosted Motorola
  203. Freeware 8 bit cross assemblers.  It details the features and
  204. capabilities of the cross assemblers, assembler syntax and directives,
  205. options, and listings. It is intended as a detailed reference and an
  206. introduction for those unfamiliar with Motorola assembler syntax and
  207. format.  Those experienced with Motorola assembler products may wish
  208. to examine the file ASEMBLER.DOC available with the cross assemblers,
  209. which briefly describes the differences between these assemblers and
  210. earlier, non-pc based versions.
  211.  
  212. Assemblers are programs that process assembly language source program
  213. statements and translate them into executable machine language object
  214. files.  A programmer writes his source program using any text editor
  215. or word processor that can produce an ASCII text output.  With some
  216. word processors this is known as "non document" mode.  Non document
  217. mode produces a file without the non-printable embedded control
  218. characters that are used in document formating.  (Caution: assembling
  219. a file that has been formatted with embedded control characters may
  220. produce assembler errors.  The solution is to convert the source file
  221. to ASCII text.) Once the source code is written, the source file is
  222. assembled by processing the file via the assembler.
  223.  
  224. Cross assemblers (such as the Motorola Freeware Assemblers) allow
  225. source programs written and edited on one computer (the host) to
  226. generate executable code for another computer (the target).  The
  227. executable object file can then be downloaded and run on the target
  228. system.  In this case the host is an IBM-PC or compatible and the
  229. target system is based on a Motorola 8-bit microprocessor (6800, 6801,
  230. 6803, 6805, 68HC05, 6809, or 68HC11).
  231.  
  232. The assemblers are the executable programs AS*.EXE where * is any of
  233. 0, 1, 4, 5, 9, or 11 depending on which microprocessor you are writing
  234. code for.  The details of executing the assembler programs are found
  235. in Chapter 3.  The assembly language format and syntax for the various
  236. processors is very similar with slight variations due to varied
  237. programming resources (instructions, addressing modes, and registers).
  238. These variations are explained in Appendix B.
  239.  
  240.  
  241. 1.2   ASSEMBLY LANGUAGE
  242.  
  243. The symbolic language used to code source programs to be processed by
  244. the Assembler is called assembly language. The language is a
  245. collection of mnemonic symbols representing: operations (i.e., machine
  246. instruction mnemonics or directives to the assembler), symbolic names,
  247. operators, and special symbols. The assembly language provides
  248. mnemonic operation codes for all machine instructions in the
  249. instruction set. The instructions are defined and explained in the
  250. Programming Reference Manuals for the specific devices, available from
  251. Motorola. The assembly language also contains mnemonic directives
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.                                    Freeware Assemblers User's Manual
  260.  
  261.  
  262. which specify auxiliary actions to be performed by the Assembler.
  263. These directives are not always translated into machine language.
  264.  
  265.  
  266. 1.3   OPERATING ENVIRONMENT
  267.  
  268. These assemblers will run on any IBM-PC, XT, AT, PS-2, or true
  269. compatible.  The assemblers may be run off of a floppy disk drive or
  270. they may be copied onto a hard drive for execution.  DOS 2.0 or later
  271. is required.
  272.  
  273.  
  274. 1.4   ASSEMBLER PROCESSING
  275.  
  276. The Macro Assembler is a two-pass assembler. During the first pass,
  277. the source program is read to develop the symbol table. During the
  278. second pass, the object file is created (assembled) with reference to
  279. the table developed in pass one. It is during the second pass that
  280. the source program listing is also produced.
  281.  
  282. Each source statement is processed completely before the next source
  283. statement is read. As each statement is processed, the Assembler
  284. examines the label, operation code, and operand fields. The operation
  285. code table is scanned for a match with a known opcode.  During the
  286. processing of a standard operation code mnemonic, the standard
  287. machine code is inserted into the object file. If an Assembler
  288. directive is being processed, the proper action is taken.
  289.  
  290. Any errors that are detected by the Assembler are displayed before the
  291. actual line containing the error is printed. If no source listing is
  292. being produced, error messages are still displayed to indicate that
  293. the assembly process did not proceed normally.
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.                                  2
  321.  
  322.  
  323.  
  324.  
  325.                                    Freeware Assemblers User's Manual
  326.  
  327.  
  328.                               CHAPTER 2 
  329.                    CODING ASSEMBLY LANGUAGE PROGRAMS
  330.  
  331.  
  332. 2.1   INTRODUCTION
  333.  
  334. Programs written in assembly language consist of a sequence of source
  335. statements. Each source statement consists of a sequence of ASCII
  336. characters ending with a carriage return.  Appendix A contains a list
  337. of the supported character set.
  338.  
  339.  
  340. 2.2   SOURCE  STATEMENT FORMAT
  341.  
  342. Each source statement may include up to four fields:  a label (or "*"
  343. for a comment line), an operation (instruction mneumonic or assembler
  344. directive), an operand, and a comment.
  345.  
  346.  
  347. 2.2.1   Label Field
  348.  
  349. The label field occurs as the first field of a source statement. The
  350. label field can take one of the following forms:
  351.  
  352. 1. An asterisk (*) as the first character in the label field indicates
  353. that the rest of the source statement is a comment. Comments are
  354. ignored by the Assembler, and are printed on the source listing only
  355. for the programmer's information.
  356.  
  357. 2. A whitespace character (blank or tab) as the first character
  358. indicates that the label field is empty. The line has no label and is
  359. not a comment.
  360.  
  361. 3. A symbol character as the first character indicates that the line
  362. has a label. Symbol characters are the upper or lower case letters a-
  363. z,  digits 0-9, and the special characters, period (.), dollar sign
  364. ($), and underscore (_). Symbols consist of one to 15 characters, the
  365. first of which must be alphabetic or the special characters period (.)
  366. or underscore (_).  All characters are significant and upper and lower
  367. case letters are distinct.
  368.  
  369. A symbol may occur only once in the label field. If a symbol does
  370. occur more than once in a label field, then each reference to that
  371. symbol will be flagged with an error.
  372.  
  373. With the exception of some directives, a label is assigned the value
  374. of the program counter of the first byte of the instruction or data
  375. being assembled. The value assigned to the label is absolute.
  376. Labels may optionally be ended with a colon (:).  If the colon is
  377. used it is not part of the label but merely acts to set the label off
  378. from the rest of the source line.  Thus the following code fragments
  379. are equivalent:
  380.  
  381.      here:  deca
  382.             bne here
  383.  
  384.  
  385.  
  386.                                  3
  387.  
  388.  
  389.  
  390.  
  391.                                    Freeware Assemblers User's Manual
  392.  
  393.  
  394.      here   deca
  395.             bne here
  396.  
  397. A label may appear on a line by itself.  The assembler interprets this
  398. as set the value of the label equal to the current value of the
  399. program counter.
  400.  
  401. The symbol table has room for at least 2000 symbols of length 8
  402. characters or less.  Additional characters up to 15 are permissible at
  403. the expense of decreasing the maximum number of symbols possible in
  404. the table.
  405.  
  406.  
  407. 2.2.2   Operation Field
  408.  
  409. The operation field occurs after the label field, and must be preceded
  410. by at least one whitespace character. The operation field must contain
  411. a legal opcode mneumonic or an assembler directive.  Upper case
  412. characters in this field are converted to lower case before being
  413. checked as a legal mneumonic.  Thus 'nop', 'NOP', and 'NoP' are
  414. recognized as the same mneumonic. Entries in the operation field may
  415. be one of two types:
  416.  
  417. Opcode. These correspond directly to the machine instructions. The
  418. operation code includes any register name associated with the
  419. instruction.  These register names must not be separated from the
  420. opcode with any whitespace characters.  Thus 'clra' means clear
  421. accumulator A, but 'clr a' means clear memory location identified by
  422. the label 'a'.
  423.  
  424. Directive. These are special operation codes known to the Assembler
  425. which control the assembly process rather than being translated into
  426. machine instructions.
  427.  
  428.  
  429. 2.2.3   Operand Field
  430.  
  431. The operand field's interpretation is dependent on the contents of the
  432. operation field. The operand field, if required, must follow the
  433. operation field, and must be preceded by at least one whitespace
  434. character. The operand field may contain a symbol, an expression, or a
  435. combination of symbols and expressions separated by commas.
  436.  
  437. The operand field of machine instructions is used to specify the
  438. addressing mode of the instruction, as well as the operand of the
  439. instruction.   The following tables summarize the operand field
  440. formats for the various processor families. (NOTE:  in these tables
  441. parenthesis "()" signify optional elements and angle brackets "<>"
  442. denote an expression is inserted.  These syntax elements are present
  443. only for clarification of the format and are not inserted as part of
  444. the actual source program.  All other characters are significant and
  445. must be used when required.)
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.                                  4
  453.  
  454.  
  455.  
  456.  
  457.                                    Freeware Assemblers User's Manual
  458.  
  459.  
  460. 2.2.3.1  M6800/6801 Operand Syntax
  461.  
  462. The format of the operand field for M6800/6801 instructions is:
  463.  
  464.      Operand Format           M6800/M6801 Addressing Mode
  465.      --------------           ---------------------------
  466.      no operand               accumulator and inherent
  467.      <expression>             direct, extended, or relative
  468.      #<expression>            immediate
  469.      <expression>,X           indexed
  470.  
  471. Details of the M6800/6801 addressing modes may be found in Appendix B.
  472.  
  473.  
  474. 2.2.3.2  M6804/68HC Operand Syntax
  475.  
  476. For the M6804/68HC04, the following operand formats exist:
  477.  
  478.      Operand Format                M6804/68HC04 Addressing Mode
  479.      --------------                ----------------------------
  480.      no operand                    accumulator and inherent
  481.      <expression>                  direct, extended, or relative
  482.      #<expression>                 immediate
  483.      <expression>                  bit set or clear
  484.      <expression>,<expression>     bit test and branch
  485.      [<x> or <y>]                  register indirect
  486.      <expression>,#<expression>    move indirect
  487.  
  488. Details of the M6804/68HC04 addressing modes may be found in Appendix
  489. B.
  490.  
  491.  
  492. 2.2.3.3  M6805/M68HC05 Operand Syntax
  493.  
  494. For the M6805/68HC05, the operand formats are:
  495.  
  496.      Operand Format                M6805/68HC05 Addressing Mode
  497.      --------------                ----------------------------
  498.      no operand                    accumulator and inherent
  499.      <expression>                  direct, extended, or relative
  500.      #<expression>                 immediate
  501.      <expression>,X                indexed
  502.      <expression>,<expression>     bit set or clear
  503.      <expression>,<expression>,<expression>     bit test and branch
  504.  
  505. Details of the M6805/68HC05 addressing modes may be found in Appendix
  506. B.
  507.  
  508.  
  509. 2.2.3.4  M6809 Operand Syntax
  510.  
  511. For the M6809, the following  operand formats are used:
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.                                  5
  519.  
  520.  
  521.  
  522.  
  523.                                    Freeware Assemblers User's Manual
  524.  
  525.  
  526.      Operand Format           M6809 Addressing Mode
  527.      --------------           ---------------------
  528.      no operand               accumulator and inherent
  529.      <expression>             direct, extended, or relative
  530.      #<expression>            immediate
  531.      <expression>,X           indexed
  532.      <<expression>            forced direct
  533.      ><expression>            forced extended
  534.      <expression>]            extended indirect
  535.      <expression>,R           indexed
  536.      <<expression>,R          forced 8-bit offset indexed
  537.      ><expression>,R          forced 16-bit offset indexed
  538.      [<expression>,R]         indexed indirect
  539.      <[<expression>,R]        forced 8-bit offset indexed indirect
  540.      >[<expression>,R]        forced 16-bit offset indexed indirect
  541.      Q+                       auto increment by 1
  542.      Q++                      auto increment by 2
  543.      [Q++]                    auto increment indirect
  544.      -Q                       auto decrement by
  545.      --Q                      auto decrement by 2
  546.      [--Q]                    auto decrement indirect
  547.      W1,[W2,...,Wn]           immediate
  548.  
  549. where R is one of the registers PCR, S, U, X, or Y, and Q is one of
  550. the registers S, U, X, or Y.   Wi  (i=1 to n) is one of the symbols A,
  551. B, CC, D, DP, PC, S, U, X, or Y.
  552.  
  553. Details of the M6809 addressing modes may be found in Appendix B.
  554.  
  555.  
  556. 2.2.3.5  M68HC11 Operand Syntax
  557.  
  558. For the M68HC11, the following operand formats exist:
  559.  
  560.      Operand Format                M68HC11 Addressing Mode
  561.      --------------                -----------------------
  562.      no operand                    accumulator and inherent
  563.      <expression>                  direct, extended, or relative
  564.      #<expression>                 immediate
  565.      <expression>,X                indexed with X register
  566.      <expression>,Y                indexed with Y register
  567.      <expression> <expression>     bit set or clear
  568.      <expression> <expression> <expression>     bit test and branch
  569.  
  570. The bit manipulation instruction operands are separated by spaces in
  571. this case since the HC11 allows bit manipulation instructions on
  572. indexed addresses.  Thus a ',X' or ',Y' may be added to the final two
  573. formats above to form the indexed effective address calculation.
  574.  
  575. Details of the M68HC11 addressing modes may be found in Appendix B.
  576. The operand fields of assembler directives are described in Chapter 4.
  577.  
  578.  
  579. 2.2.3.6  Expressions.  An expression is a combination of symbols,
  580. constants, algebraic operators, and parentheses. The expression is
  581. used to specify a value which is to be used as an operand.
  582.  
  583.  
  584.                                 6
  585.  
  586.  
  587.  
  588.  
  589.                                    Freeware Assemblers User's Manual
  590.  
  591.  
  592. Expressions may consist of symbols, constants, or the character '*'
  593. (denoting the current value of the program counter) joined together by
  594. one of the operators: + - * / % & | ^ .
  595.  
  596.  
  597. 2.2.3.7  Operators.  The operators are the same as in c:
  598.  
  599.      +    add
  600.      -    subtract
  601.      *    multiply
  602.      /    divide
  603.      %    remainder after division
  604.      &    bitwise and
  605.      |    bitwise or
  606.      ^    bitwise exclusive or
  607.  
  608. Expressions are evaluated left to right and there is no provision for
  609. parenthesized expressions.  Arithmetic is carried out in signed two-
  610. complement integer precision (that's 16 bits on the IBM PC).
  611.  
  612.  
  613. 2.2.3.8  Symbols.  Each symbol is associated with a 16-bit integer
  614. value which is used in place of the symbol during the expression
  615. evaluation.  The asterisk (*) used in an expression as a symbol
  616. represents the current value of the location counter (the first byte
  617. of a multi-byte instruction).
  618.  
  619.  
  620. 2.2.3.9  Constants.  Constants represent quantities of data that do
  621. not vary in value during the execution of a program.  Constants may be
  622. presented to the assembler in one of five formats: decimal,
  623. hexadecimal, binary, or octal, or ASCII.  The programmer indicates the
  624. number format to the assembler with the following prefixes:
  625.  
  626.      $    HEX            or trailing H
  627.      %    BINARY         or trailing B
  628.      @    OCTAL          or trailing Q
  629.      '    ASCII
  630.  
  631. Unprefixed constants are interpreted as decimal.  The assembler
  632. converts all constants to binary machine code and are displayed in the
  633. assembly listing as hex.
  634.  
  635. A decimal constant consists of a string of numeric digits. The value
  636. of a decimal constant must fall in the range 0-65535, inclusive.  The
  637. following example shows both valid and invalid decimal constants:
  638.  
  639.      VALID     INVALID   REASON INVALID
  640.      -----     -------   --------------
  641.      12        123456    more than 5 digits
  642.      12345     12.3      invalid character
  643.  
  644. A hexadecimal constant consists of a maximum of four characters from
  645. the set of digits (0-9) and the upper case alphabetic letters (A-F),
  646. and is preceded by a dollar sign ($).  Hexadecimal constants must be
  647.  
  648.  
  649.  
  650.                                  7
  651.  
  652.  
  653.  
  654.  
  655.                                    Freeware Assemblers User's Manual
  656.  
  657.  
  658. in the range $0000 to $FFFF. The following example shows both valid
  659. and invalid hexadecimal constants:
  660.  
  661.      VALID     INVALID   REASON INVALID
  662.      -----     -------   --------------
  663.      $12       ABCD      no preceding "$"
  664.      $ABCD     $G2A      invalid character
  665.      $001F     $2F018    too many digits
  666.  
  667. A binary constant consists of a maximum of 16 ones or zeros preceded
  668. by a percent sign (%).  The following example shows both valid and
  669. invalid binary constants:
  670.  
  671.      VALID     INVALID             REASON INVALID
  672.      -----     -------             --------------
  673.      %00101    1010101             missing percent
  674.      %1        %10011000101010111  too many digits
  675.      %10100    %210101             invalid digit
  676.  
  677. An octal constant consists of a maximum of six numeric digits,
  678. excluding the digits 8 and 9, preceded by a commercial at-sign (@).
  679. Octal constants must be in the ranges @0 to @177777.  The following
  680. example shows both valid and invalid octal constan
  681. ts:
  682.  
  683.      VALID     INVALID   REASON INVALID
  684.      -----     -------   --------------
  685.      @17634    @2317234  too many digits
  686.      @377      @277272   out of range
  687.      @177600   @23914    invalid character
  688.  
  689. A single ASCII character can be used as a constant in expressions.
  690. ASCII constants are preceded by a single quote ('). Any character,
  691. including the single quote, can be used as a character constant.   The
  692. following example shows both valid and inval
  693. id character constants:
  694.  
  695.      VALID     INVALID   REASON INVALID
  696.      -----     -------   --------------
  697.      '*        'VALID    too long
  698.  
  699. For the invalid case above the assembler will not indicate an error.
  700. Rather it will assemble the first character and ignore the remainder.
  701.  
  702.  
  703. 2.2.4   Comment Field
  704.  
  705. The last field of an Assembler source statement is the comment field.
  706. This field is optional and is only printed on the source listing for
  707. documentation purposes. The comment field is separated from the
  708. operand field (or from the operation field if no operand is required)
  709. by at least one whitespace character. The comment field can contain
  710. any printable ASCII characters.
  711.  
  712. Comments may also begin with a semicolon.  When a semicolon is used
  713. the comment may begin in any column.
  714.  
  715.  
  716.                                  8
  717.  
  718.  
  719.  
  720.  
  721.                                    Freeware Assemblers User's Manual
  722.  
  723.  
  724. 2.3   ASSEMBLER OUTPUT
  725.  
  726. The Assembler output includes an optional listing of the source
  727. program and an object file which is in the Motorola S Record format.
  728. Details of the S Record format may be found in Appendix E.   The
  729. Assembler will normally suppress the printing of the source listing.
  730. This condition, as well as others, can be overridden via options
  731. supplied on the command line that invoked the Assembler.
  732.  
  733. Each line of the listing contains a reference line number, the address
  734. and bytes assembled, and the original source input line.  If an input
  735. line causes more than 6 bytes to be output (e.g. a long FCC
  736. directive), additional bytes (up to 64) are listed on succeeding lines
  737. with no address preceding them.
  738.  
  739. The assembly listing may optionally contain a symbol table or a cross
  740. reference table of all symbols appearing in the program. These are
  741. always printed at the end of the assembly listing if either the symbol
  742. table or cross reference table options (Paragraph 4.8) are in effect.
  743. The symbol table contains the name of each symbol, along with its
  744. defined value. The cross reference table additionally contains the
  745. assembler-maintained source line number of every reference to every
  746. symbol. The format of the cross reference table is shown in Appendix
  747. D.
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.                                  9
  783.  
  784.  
  785.  
  786.  
  787.                                    Freeware Assemblers User's Manual
  788.  
  789.  
  790.                               CHAPTER 3
  791.                         RUNNING THE ASSEMBLERS
  792.  
  793.  
  794. 3.1   ASSEMBLER INVOCATION
  795.  
  796. The Motorola Freeware Assembly programs are named as*.exe where '*' is
  797. any of 0, 1, 4, 5, 9, or 11 depending on which processor family you
  798. wish to assemble code for.  For example, to generate M6800 code run
  799. the as0.exe program.  To generate M68HC05 code run the as5.exe
  800. program, and so forth.  To run the assembler enter the following
  801. command line:
  802.  
  803.          as*   file1 (file2 . . . ) ( - option1 option2 . . . )
  804.  
  805. where file1, file2, etc are the names of the source files you wish to
  806. assemble.  The source filenames may have extensions but the assembler
  807. does not check for any particular extension ( however, do not use the
  808. .S19 extension since that is the extension of the object file created
  809. by the assembler.  Its creation would overwrite the source file when
  810. it is written to the disk).
  811.  
  812. The options are one or more of the following:
  813.  
  814.      l    enables output listing
  815.      no   disables output listing (default).
  816.      cre  enables the cross reference table generation
  817.      s    enables the symbol table generation
  818.      c    enables cycle counting
  819.      noc  disables cycle counting
  820.  
  821. The minus sign preceding the option should be separated from the last
  822. file name by a space.  These options may also be indicated to the
  823. assembler by the use of the OPT directive in the source file.  The OPT
  824. directive is described in Paragraph 4.8.
  825.  
  826. The object file created is written to disk and given the name
  827. 'FILENAME.S19' where 'FILENAME' is the name of the first source file
  828. specified on the command line.  Any errors and the optional listing
  829. (if specified) are displayed on the screen.  The listing and/or error
  830. messages may be saved to a file for later examination or printing by
  831. append an i/o redirection command to the command line.  On the PC i/o
  832. redirection is indicated with the greater-than ('>') symbol followed
  833. by any new or existing file name.
  834.  
  835. Command line examples:
  836.  
  837. The command line
  838.  
  839.          as5 myfile
  840.  
  841. would run the M6805/68HC05 assembler on the source file 'myfile'.  The
  842. object file would be written to 'myfile.s19' and any errors would
  843. appear on the screen.
  844.  
  845.  
  846.  
  847.  
  848.                                  10
  849.  
  850.  
  851.  
  852.  
  853.                                    Freeware Assemblers User's Manual
  854.  
  855.  
  856. The command line
  857.  
  858.          as9 test.asm nexttest.s -l
  859.  
  860. would run the M6809 assembler on the source files 'test.asm' and
  861. 'nexttest.s'.  The object file would be written to 'test.s19' and any
  862. errors and the assembly listing would appear on the screen.
  863.  
  864. The command line
  865.  
  866.          as9 test.asm nexttest.s -l cre s >test.lst
  867.  
  868. would run the M6809 assembler on the source files 'test.asm' and
  869. 'nexttest.s'.  The object file would be written to 'test.s19'.  A
  870. listing would be created followed by a symbol table and cross
  871. reference which would all be written to the file test.lst
  872. .
  873.  
  874. 3.2   ERROR MESSAGES
  875.  
  876. Error diagnostic messages are placed in the listing file just before
  877. the line containing the error.  The format of the error line is:
  878.  
  879.              Line_number:   Description of error
  880.  
  881.                                   or
  882.  
  883.              Line_number:   Warning ---- Description of error
  884.  
  885. Errors in pass one cause cancellation of pass two.  Warning do not
  886. cause cancellation of pass two but are indications of a possible
  887. problem.  Error messages are meant to be self-explanatory.
  888.  
  889. If more than one file is being assembled, the file name precedes the
  890. error:
  891.  
  892.              File_name,Line_number:  Description of error
  893.  
  894. Some errors are classed as fatal and cause an immediate termination of
  895. the assembly.  Generally this happens when a temporary file cannot be
  896. created or is lost during assembly.
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.                                 11
  915.  
  916.  
  917.  
  918.  
  919.                                    Freeware Assemblers User's Manual
  920.  
  921.  
  922.                               CHAPTER 4
  923.                          ASSEMBLER DIRECTIVES
  924.  
  925.  
  926. 4.1   INTRODUCTION
  927.  
  928. The Assembler directives are instructions to the Assembler, rather
  929. than instructions to be directly translated into object code. This
  930. chapter describes the directives that are recognized by the Freeware
  931. Assemblers. Detailed descriptions of each directive are arranged
  932. alphabetically. The notations used in this chapter are:
  933.  
  934.   ( )  Parentheses denote an optional element.
  935.  
  936.   XYZ  The names of the directives are printed in capital letters.
  937.  
  938.   < >  The element names are printed in lower case and contained in
  939. angle brackets.  All elements outside of the angle brackets '<>' must
  940. be specified as-is. For example, the syntactical element (<number>,)
  941. requires the comma to be specified if the optional element <number> is
  942. selected. The following elements are used in the subsequent
  943. descriptions:
  944.  
  945.  
  946.      <comment>      A statement's comment field
  947.      <label>        A statement label
  948.      <expression>   An Assembler expression
  949.      <expr>         An Assembler expression
  950.      <number>       A numeric constant
  951.      <string>       A string of ASCII characters
  952.      <delimiter>    A string delimiter
  953.      <option>       An Assembler option
  954.      <symbol>       An Assembler symbol
  955.      <sym>          An Assembler symbol
  956.      <sect>         A relocatable program section
  957.      <reg list>     M6809 register list
  958.      <reg exp>      M6809 register expression
  959.  
  960.  
  961. In the following descriptions of the various directives, the syntax,
  962. or format, of the directive is given first.  This will be followed
  963. with the directive's description.
  964.  
  965. 4.2   BSZ - BLOCK STORAGE OF ZEROS
  966.  
  967.                    (<label>) BSZ <expression> (<comment>)
  968.  
  969. The BSZ directive causes the Assembler to allocate a block of bytes.
  970. Each byte is assigned the initial value of zero. The number of bytes
  971. allocated is given by the expression in the operand field. If the
  972. expression contains symbols that are either undefined or forward
  973. referenced (i.e. the definition occurs later on in the file), or if
  974. the expression has a value of zero, an error will be generated.
  975.  
  976.  
  977.  
  978.  
  979.  
  980.                                  12
  981.  
  982.  
  983.  
  984.  
  985.                                    Freeware Assemblers User's Manual
  986.  
  987.  
  988. 4.3   EQU - EQUATE SYMBOL TO A VALUE
  989.  
  990.                    <label> EQU <expression> (<comment>)
  991.  
  992. The EQU directive assigns the value of the expression in the operand
  993. field to the label. The EQU directive assigns a value other than the
  994. program counter to the label. The label cannot be redefined anywhere
  995. else in the program.  The expression cannot contain any forward
  996. references or undefined symbols.  Equates with forward references are
  997. flagged with Phasing Errors.
  998.  
  999. 4.4   FCB - FORM CONSTANT BYTE or DB - DEFINE BYTE
  1000.  
  1001.          (<label>) FCB <expr>(,<expr>,...,<expr>) (<comment>)
  1002.  
  1003. The FCB directive may have one or more operands separated by commas.
  1004. The value of each operand is truncated to eight bits, and is stored in
  1005. a single byte of the object program.  Multiple operands are stored in
  1006. successive bytes. The operand may be a numeric constant, a character
  1007. constant, a symbol, or an expression. If multiple operands are
  1008. present, one or more of them can be null (two adjacent commas), in
  1009. which case a single byte of zero will be assigned for that operand.
  1010. An error will occur if the upper eight bits of the evaluated operands'
  1011. values are not all ones or all zeros.
  1012.  
  1013. 4.5   FCC - FORM CONSTANT CHARACTER STRING
  1014.  
  1015.          (<label>) FCC <delimiter><string><delimiter> (<comment>)
  1016.  
  1017. The FCC  directive is used to store ASCII strings into consecutive
  1018. bytes of memory.  The byte storage begins at the current program
  1019. counter.  The label is assigned to the first byte in the string. Any
  1020. of the printable ASCII characters can be contained in the string.  The
  1021. string is specified  between two identical delimiters which can be any
  1022. printable ASCII character. The first non-blank character after the FCC
  1023. directive is used as the delimiter.
  1024.  
  1025. Example:
  1026.  
  1027.      LABEL1    FCC  , ABC,
  1028.  
  1029. assembles ASCII ABC at location LABEL1
  1030.  
  1031.  
  1032. 4.6 FDB - FORM DOUBLE BYTE CONSTANT or DW - DEFINE WORD
  1033.  
  1034.          (<label>) FDB <expr>(,<expr>,...,<expr>) (<comment>)
  1035.  
  1036. The FDB directive may have one or more operands separated by commas.
  1037. The 16-bit value corresponding to each operand is stored into two
  1038. consecutive bytes of the object program.  The storage begins at the
  1039. current program counter.  The label is assigned to the first 16-bit
  1040. value. Multiple operands are stored in successive bytes.  The operand
  1041. may be a numeric constant, a character constant, a symbol, or an
  1042. expression. If multiple operands are present, one or more of them can
  1043.  
  1044.  
  1045.  
  1046.                                  13
  1047.  
  1048.  
  1049.  
  1050.  
  1051.                                    Freeware Assemblers User's Manual
  1052.  
  1053.  
  1054. be null (two adjacent commas), in which case two bytes of zeros will
  1055. be assigned for that operand.
  1056.  
  1057. 4.7 FILL - FILL MEMORY
  1058.  
  1059.                    (<label>) FILL <expression>,<expression>
  1060.  
  1061. The FILL directive causes the assembler to initialize an area of
  1062. memory with a constant value.  The first expression signifies the one
  1063. byte value to be placed in the memory and the second expression
  1064. indicates the total number of successive bytes to be initialized.  The
  1065. first expression must evaluate to the range 0-255.  Expressions cannot
  1066. contain forward references or undefined symbols.
  1067.  
  1068. 4.8 OPT - ASSEMBLER OUTPUT OPTIONS
  1069.  
  1070.          OPT <option>(,<option>,...,<option>) (<comment>)
  1071.  
  1072. The OPT directive is used to control the format of the Assembler
  1073. output. The options are specified in the operand field, separated by
  1074. commas. All options have a default condition.  Some options can be
  1075. initialized from the command line that invoked the Assembler, however
  1076. the options contained in the source file take precedence over any
  1077. entered on the command line. In the following descriptions, the
  1078. parenthetical inserts specify "DEFAULT", if the option is the default
  1079. condition.  All options must be entered in lower case.
  1080.  
  1081.   c -  Enable cycle counting in the listing.  The total cycle count
  1082. for that instruction will appear in the listing after the assembled
  1083. bytes and before the source code.
  1084.  
  1085.   cre -  Print a cross reference table at the end of the source
  1086. listing. This option, if used, must be specified before the first
  1087. symbol in the source program is encountered.  The cross reference
  1088. listing format may be found in Appendix D.
  1089.  
  1090.    l -  Print the listing from this point on.  A description of the
  1091. listing format can be found in Appendix D.
  1092.  
  1093.    noc -  (DEFAULT) Disable cycle counting in the listing.  If the "c"
  1094. option was used previously in the program, this option will cause
  1095. cycle counting to cease until the next "OPT c" statement.
  1096.  
  1097.   nol -   (DEFAULT)  Do not print the listing from this point on.  An
  1098. "OPT l" can re-enble listing at a later point in the program.
  1099.  
  1100.    s -  Print symbol table at end of source listing.  The symbol table
  1101. format can be found in Appendix D.
  1102.  
  1103.  
  1104. 4.9 ORG - SET PROGRAM COUNTER TO ORIGIN
  1105.  
  1106.                    ORG <expression> (<comment>)
  1107.  
  1108. The ORG directive changes the program counter to the value specified
  1109. by the expression in the operand field. Subsequent statements are
  1110.  
  1111.  
  1112.                                  14
  1113.  
  1114.  
  1115.  
  1116.  
  1117.                                    Freeware Assemblers User's Manual
  1118.  
  1119.  
  1120. assembled into memory locations starting with the new program counter
  1121. value. If no ORG directive is encountered in a source program, the
  1122. program counter is initialized to zero.  Expressions cannot contain
  1123. forward references or undefined symbols.
  1124.  
  1125.  
  1126. 4.10 PAGE - TOP OF PAGE
  1127.  
  1128.                    PAGE
  1129.  
  1130. The PAGE directive causes the Assembler to advance the paper to the
  1131. top of the next page. If no source listing is being produced, the PAGE
  1132. directive will have no effect. The directive is not printed on the
  1133. source listing.
  1134.  
  1135.  
  1136. 4.11 RMB - RESERVE MEMORY BYTES or DS - DEFINE(reserve) STORAGE
  1137.  
  1138.                 (<label>) RMB <expression> (<comment>)
  1139.  
  1140. The RMB directive causes the location counter to be advanced by the
  1141. value of the expression in the operand field. This directive reserves
  1142. a block of memory the length of which in bytes is equal to the value
  1143. of the expression. The block of memory reserved is not initialized to
  1144. any given value. The expression cannot contain any forward references
  1145. or undefined symbols.  This directive is commonly used to reserve a
  1146. scratchpad or table area for later use.
  1147.  
  1148. 4.12 ZMB - ZERO MEMORY BYTES  (same as BSZ)
  1149.  
  1150.                   (<label>) ZMB <expression> (<comment>)
  1151.  
  1152. The ZMB directive causes the Assembler to allocate a block of bytes.
  1153. Each byte is assigned the initial value of zero. The number of bytes
  1154. allocated is given by the expression in the operand field. If the
  1155. expression contains symbols that are either undefined or forward
  1156. references, or if the expression has a value of zero, an error will be
  1157. generated.
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.                                  15
  1179.  
  1180.  
  1181.  
  1182.  
  1183.                                    Freeware Assemblers User's Manual
  1184.  
  1185.  
  1186.                                APPENDIX A
  1187.                               CHARACTER SET
  1188.  
  1189.  
  1190. The character set recognized by the Freeware Assemblers is a subset of
  1191. ASCII. The ASCII code is shown in the following figure. The following
  1192. characters are recognized by the Assembler:
  1193.  
  1194.         1. The upper case letters A through Z and lower case letters a
  1195.            through z.
  1196.  
  1197.         2. The digits 0 through 9.
  1198.  
  1199.         3. Five arithmetic operators:  +, -, *, / and % (remainder
  1200.            after division).
  1201.  
  1202.         4. Three logical operators:  &, |, and ^.
  1203.  
  1204.         5. The special symbol characters:  underscore (_), period (.),
  1205.            and dollar sign ($).  Only the underscore and period may be
  1206.            used as the first character of a symbol.
  1207.  
  1208.         6. The characters used as prefixes for constants and
  1209.            addressing modes:
  1210.  
  1211.                #    Immediate addressing
  1212.                $    Hexadecimal constant
  1213.                &    Decimal constant
  1214.                @    Octal constant
  1215.                %    Binary constant
  1216.                '    ASCII character constant
  1217.  
  1218.         7. The characters used as suffixes for constants and
  1219.            addressing modes:
  1220.  
  1221.                ,X   Indexed addressing
  1222.                ,PCR M6809 indexed addressing
  1223.                ,S   M6809 indexed addressing
  1224.                ,U   M6809 indexed addressing
  1225.                ,Y   M6809 and M68HC11 indexed addressing
  1226.  
  1227.         8. Three separator characters:  space, carriage return, and
  1228.            comma.
  1229.  
  1230.         9. The character "*" to indicate comments.  Comments may
  1231.            contain any printable characters from the ASCII set.
  1232.  
  1233.        10. The special symbol backslash "\" to indicate line
  1234.            continuation.  When the assembler encounters the line
  1235.            continuation character it fetches the next line and adds it
  1236.            to the end of the first line.  This continues until a line
  1237.            is seen which doesn't end with a backslash or until the
  1238.            system maximum buffer size has been collected (typically
  1239.            greater or equal to 256).
  1240.  
  1241.  
  1242.  
  1243.  
  1244.                                 16
  1245.  
  1246.  
  1247.  
  1248.  
  1249.                                    Freeware Assemblers User's Manual
  1250.  
  1251.  
  1252.        11. For the M6809 Assembler, the character "<" preceding an
  1253.            expression to indicate direct addressing mode or 8-bit
  1254.            offset in indexed mode, and the character ">" preceding an
  1255.            expression to indicate extended addressing mode or 16-bit
  1256.            offset in indexed mode.
  1257.  
  1258.       12. For the M6809 Assembler, the characters used to indicate
  1259.           auto increment and auto decrement in the indexed mode:  +,
  1260.           ++, -, --.
  1261.  
  1262.  
  1263.  
  1264.  
  1265.                          ASCII CHARACTER CODES
  1266.  
  1267.  
  1268.            BITS 4 to 6 -- 0    1    2    3    4    5    6    7
  1269.            -----------    ------------------------------------- 
  1270.  
  1271.                      0    NUL  DLE  SP   0    @    P    `    p
  1272.                 B    1    SOH  DC1  :    1    A    Q    a    q
  1273.                 I    2    STX  DC2  !    2    B    R    b    r
  1274.                 T    3    ETX  DC3  #    3    C    S    c    s
  1275.                 S    4    EOT  DC4  $    4    D    T    d    t
  1276.                      5    ENQ  NAK  %    5    E    U    e    u
  1277.                 0    6    ACK  SYN  &    6    F    V    f    v
  1278.                      7    BEL  ETB  '    7    G    W    g    w
  1279.                 T    8    BS   CAN  (    8    H    X    h    x
  1280.                 O    9    HT   EM   )    9    I    Y    i    y
  1281.                      A    LF   SUB  *    :    J    Z    j    z
  1282.                 3    B    VT   ESC  +    ;    K    [    k    {
  1283.                      C    FF   FS   ,    <    L    \    l    ;
  1284.                      D    CR   GS   -    =    M    ]    m    }
  1285.                      E    SO   RS   .    >    N    ^    n    ~
  1286.                      F    S1   US   /    ?    O    _    o    DEL
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.                                 17
  1311.  
  1312.  
  1313.  
  1314.  
  1315.                                    Freeware Assemblers User's Manual
  1316.  
  1317.  
  1318.                               APPENDIX B
  1319.                            ADDRESSING MODES
  1320.  
  1321. B.1   M6800/M6801 ADDRESSING MODES.
  1322.  
  1323. INHERENT OR ACCUMULATOR ADDRESSING
  1324. The M6800 includes some instructions which require no operands. These
  1325. instructions are self-contained and employ the inherent addressing or
  1326. the accumulator addressing mode.
  1327.  
  1328.  
  1329. IMMEDIATE ADDRESSING
  1330. Immediate addressing refers to the use of one or two bytes of
  1331. information that immediately follow the operation code in memory.
  1332. Immediate addressing is indicated by preceding the operand field with
  1333. the pound sign or number sign character (#). The expression following
  1334. the # will be assigned one or two bytes of storage, depending on the
  1335. instruction.
  1336.  
  1337.  
  1338. RELATIVE ADDRESSING
  1339. Relative addressing is used by branch instructions. Branches can only
  1340. be executed within the range -126 to +129 bytes relative to the first
  1341. byte of the branch instruction.  For this mode, the programmer
  1342. specifies the branch address expression and places it in the operand
  1343. field. The actual branch offset is calculated by the assembler and put
  1344. into the second byte of the branch instruction.  The offset is the
  1345. two's complement of the difference between the location of the byte
  1346. immediately following the branch instruction and the location of the
  1347. destination of the branch.  Branches out of bounds are flagged as
  1348. errors by the assembler.
  1349.  
  1350.  
  1351. INDEXED ADDRESSING
  1352. Indexed addressing is relative to the index register. The address is
  1353. calculated at the time of instruction execution by adding a one-byte
  1354. displacement (in the second byte of the instruction) to the current
  1355. contents of the X register. Since no sign extension is performed on
  1356. this one-byte displacement, the offset cannot be negative. Indexed
  1357. addressing is indicated by the characters ",X" following the
  1358. expression in the operand field. The special case of ",X", without a
  1359. preceding expression, is treated as "0,X".
  1360.  
  1361.  
  1362. DIRECT AND EXTENDED ADDRESSING
  1363. Direct and extended addressing utilize one (direct) or two (extended)
  1364. bytes to contain the address of the operand. Direct addressing is
  1365. limited to the first 256 bytes of memory. Direct and extended
  1366. addressing are indicated by only having an expression in the operand
  1367. field. Direct addressing will be used by the Assembler whenever
  1368. possible.
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.                                 18
  1377.  
  1378.  
  1379.  
  1380.  
  1381.                                    Freeware Assemblers User's Manual
  1382.  
  1383.  
  1384. B.2   M6804/M68HC04 ADDRESSING MODES.
  1385.  
  1386. INHERENT OR ACCUMULATOR ADDRESSING
  1387. The M6800 includes some instructions which require no operands. These
  1388. instructions are self-contained and employ the inherent addressing or
  1389. the accumulator addressing mode.
  1390.  
  1391.  
  1392. IMMEDIATE ADDRESSING
  1393. Immediate addressing refers to the use of one byte of information that
  1394. immediately follows the operation code in memory. Immediate addressing
  1395. is indicated by preceding the operand field with the pound sign or
  1396. number sign character (#). The expression following the # will be
  1397. assigned one byte of storage.
  1398.  
  1399.  
  1400. RELATIVE ADDRESSING
  1401. Relative addressing is used by branch instructions. Branches can only
  1402. be executed within the range -15 to +16 bytes relative to the first
  1403. byte of the branch instruction.  For this mode, the programmer
  1404. specifies the branch address expression and places it in the operand
  1405. field. The actual branch offset is calculated by the assembler and put
  1406. into the second byte of the branch instruction.  The offset is the
  1407. two's complement of the difference between the location of the byte
  1408. immediately following the branch instruction and the location of the
  1409. destination of the branch.  Branches out of bounds are flagged as
  1410. errors by the assembler.
  1411.  
  1412.  
  1413. DIRECT AND EXTENDED ADDRESSING
  1414. Direct and extended addressing utilize byte to contain the address of
  1415. the operand. Direct addressing is limited to the first 256 bytes of
  1416. memory.  Extended addressing concatenates the four least-significant
  1417. bits of the opcode with the byte following the opcode to form a 12-bit
  1418. address. Direct and extended addressing are indicated by only having
  1419. an expression in the operand field.  Direct addressing will be used by
  1420. the Assembler whenever possible.
  1421.  
  1422.  
  1423. SHORT DIRECT
  1424. Some opcodes allow 4 memory locations in data space ram ($80, $81,
  1425. $82, and $83 to be referenced as part of the opcode.  The opcode
  1426. determines the data space RAM location, and the instruction is only
  1427. one byte.  The X and Y registers are at locations $80 and $81,
  1428. respectively.   An expression used with short direct addressing must
  1429. not be forward referenced (that is its definition must occur before,
  1430. not after this point in the file) and must equate to the range $80-
  1431. $83.
  1432.  
  1433.  
  1434. BIT SET AND CLEAR
  1435. In the bit set/clear addressing mode, the bit to be set or cleared is
  1436. part of the opcode.  The byte following the opcode specifies the
  1437. direct address of the byte which will have the bit set or cleared.
  1438. Any bit in the 256 byte data space memory that can be written (with
  1439.  
  1440.  
  1441.  
  1442.                                 19
  1443.  
  1444.  
  1445.  
  1446.  
  1447.                                    Freeware Assemblers User's Manual
  1448.  
  1449.  
  1450. the exception of the data direction registers) can be set or cleared
  1451. with these two byte instructions.
  1452.  
  1453.  
  1454. BIT TEST AND BRANCH
  1455. The bit test and branch addressing mode is a combination of the direct
  1456. addressing and relative addressing.  The bit to be tested, and it
  1457. condition (set or clear), is included in the opcode.  The data space
  1458. address of the byte to be tested is in the single byte immediately
  1459. following the opcode byte and follows direct addressing rules.  The
  1460. third byte is sign extended by the processor during execution to form
  1461. the 12-bit relative address which is added to the program counter if
  1462. the condition is true.  This allows branches based on any readable bit
  1463. in the data space.  The branch span is -125 to +130 from the opcode
  1464. address.  The branch target address is used by the programmer to
  1465. signify the relative offset -- the assembler calculates the offset
  1466. value.  Branches out of bounds are flagged as errors by the
  1467. assembler.
  1468.  
  1469.  
  1470. REGISTER INDIRECT
  1471. In the register indirect mode, the operand is at the address in data
  1472. space pointed to by the contents of one of the indirect registers, X
  1473. or Y.  The particular indirect register is encoded in bit 4 of the
  1474. opcode by the assembler.  The assembler  operand syntax for register
  1475. indirect is
  1476.  
  1477.                     [<X> or <Y>]
  1478.  
  1479.  
  1480. MOVE IMMEDIATE
  1481. The MVI (move immediate) instruction has its own format:
  1482.  
  1483.          mvi   <expression 1>,#<expression 2>
  1484.  
  1485. where <expression 1> is a direct address and <expression 2> is the
  1486. data value to be written.
  1487.  
  1488.  
  1489. MISCELLANEOUS SYNTAX ISSUES
  1490. The registers in the 6804/HC6804 are memory locations and have
  1491. addresses assigned to them.  The assembler has predefined
  1492.  
  1493.            a = A = $FF
  1494.            b = B = $80
  1495.            c = C = $81
  1496.  
  1497. This also means that for the '04 assembler clr x is equivalent to clrx
  1498. since x is both a register and a memory location.
  1499.  
  1500. The '04 series has separate program and data spaces.  There is no
  1501. program memory in the range $10-$7F.  Bytes assembled into that range
  1502. will go into the data space.
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.                                 20
  1509.  
  1510.  
  1511.  
  1512.  
  1513.                                    Freeware Assemblers User's Manual
  1514.  
  1515.  
  1516. B.3   M6805/68HC05 ADDRESSING MODES.
  1517.  
  1518. INHERENT OR ACCUMULATOR ADDRESSING
  1519. The M6805 includes some instructions which require no operands. These
  1520. instructions are self-contained, and employ the inherent addressing or
  1521. the accumulator addressing mode.
  1522.  
  1523.  
  1524. IMMEDIATE ADDRESSING
  1525. Immediate addressing refers to the use of one byte of information that
  1526. immediately follows the operation code in memory. Immediate addressing
  1527. is indicated by preceding the operand field with the pound sign or
  1528. number sign character (#). The expression following the # will be
  1529. assigned one byte of storage.
  1530.  
  1531.  
  1532. RELATIVE ADDRESSING
  1533. Relative addressing is used by branch instructions. Branches can only
  1534. be executed within the range -126 to +129 bytes relative to the first
  1535. byte of the branch instruction. For this mode, the programmer
  1536. specifies the branch address expression and places it in the operand
  1537. field. The actual branch offset is calculated by the assembler and put
  1538. into the second byte of the branch instruction.  The offset is the
  1539. two's complement of the difference between the location of the byte
  1540. immediately following the branch instruction and the location of the
  1541. destination of the branch.  Branches out of bounds are flagged as
  1542. errors by the assembler.
  1543.  
  1544.  
  1545. INDEXED ADDRESSING
  1546. Indexed addressing is relative to the index register. The address is
  1547. calculated at the time of instruction execution by adding a one- or
  1548. two-byte displacement to the current contents of the X register. The
  1549. displacement immediately follows the operation code in memory.  If the
  1550. displacement is zero, no offset is added to the index register.  In
  1551. this case, only the operation code resides in memory.  Since no sign
  1552. extension is performed on a one-byte displacement, the offset cannot
  1553. be negative. Indexed addressing is indicated by the characters ",X"
  1554. following the expression in the operand field.  The special case of
  1555. ",X", without a preceding expression, is treated as "0,X". Some
  1556. instructions do not allow a two-byte displacement.
  1557.  
  1558.  
  1559. DIRECT AND EXTENDED ADDRESSING
  1560. Direct and extended addressing utilize one (direct) or two (extended)
  1561. bytes to contain the address of the operand. Direct addressing is
  1562. limited to the first 256 bytes of memory.  Direct and extended
  1563. addressing are indicated by only having an expression in the operand
  1564. field. Some instructions do not allow extended addressing.  Direct
  1565. addressing will be used by the Macro Assembler whenever possible.
  1566.  
  1567.  
  1568. BIT SET OR CLEAR
  1569. The addressing mode used for this type of instruction is direct,
  1570. although the format of the operand field is different from the direct
  1571. addressing mode described above. The operand takes the form
  1572.  
  1573.  
  1574.                                 21
  1575.  
  1576.  
  1577.  
  1578.  
  1579.                                    Freeware Assemblers User's Manual
  1580.  
  1581.  
  1582. <expression 1>, <expression 2>. <expression 1> indicates which bit is
  1583. to be set or cleared.  It must be an absolute expression in the range
  1584. 0-7. It is used in generating the operation code.  <expression 2> is
  1585. handled as a direct address, as described above.  Since the bit
  1586. manipulation address is direct, only the first 256 locations may be
  1587. operated on by bit manipulation operations.
  1588.  
  1589.  
  1590. BIT TEST AND BRANCH
  1591. This combines two addressing modes: direct and relative. The format of
  1592. the operand is: <expression 1>, <expression 2>, <expression 3>.
  1593. <expression 1> and <expression 2> are handled in the same manner as
  1594. described above in "bit set or clear". <expression 3> is used to
  1595. generate a relative address, as described above in "relative
  1596. addressing".
  1597.  
  1598.  
  1599. B.4  M6809 ADDRESSING MODES.
  1600.  
  1601. INHERENT OR ACCUMULATOR ADDRESSING
  1602. The M6809 includes some instructions which require no operands. These
  1603. instructions are self-contained, and employ the inherent addressing or
  1604. the accumulator addressing mode.
  1605.  
  1606.  
  1607. IMMEDIATE ADDRESSING
  1608. Immediate addressing refers to the use of one or two bytes of
  1609. information that immediately follow the operation code in memory.
  1610. Immediate addressing is indicated by preceding the operand field with
  1611. the pound sign or number sign (#) -- i.e., #<expression>.  The
  1612. expression following the # will be assigned one or two bytes of
  1613. storage, depending on the instruction. All instructions referencing
  1614. the accumulator "A" or "B", or the condition code register "CC", will
  1615. generate a one-byte immediate value. Also, immediate addressing used
  1616. with the PSHS, PULS, PSHU, and PULU instructions generates a one-byte
  1617. immediate value. Immediate operands used in all other instructions
  1618. generate a two-byte value.
  1619.  
  1620. The register list operand does not take the form #<expression> but
  1621. still generates one byte of immediate data. The form of the operand
  1622. is:
  1623.  
  1624.                             R1,R2,...,Rn
  1625.  
  1626. where Ri (i=1 to n)  is one of the symbols A, B, CC, D, DP, PC, S, U,
  1627. X or Y. The number and type of symbols vary, depending on the specific
  1628. instruction.
  1629.  
  1630. For the instructions PSHS, PULS, PSHU, and PULU, any of the above
  1631. register names may be included in the register list. The only
  1632. restriction is that "U" cannot be specified with PSHU or PULU, and "S"
  1633. cannot be specified with PSHS  or PULS. The one-byte immediate value
  1634. assigned to the operand is calculated by the assembler and is
  1635. determined by the registers specified. Each register name causes the
  1636. assembler to set a bit in the immediate byte as follows:
  1637.  
  1638.  
  1639.  
  1640.                                  22
  1641.  
  1642.  
  1643.  
  1644.  
  1645.                                    Freeware Assemblers User's Manual
  1646.  
  1647.  
  1648.           Register  Bit
  1649.           --------  ---
  1650.  
  1651.             PC      7
  1652.             U,S     6
  1653.             Y       5
  1654.             X       4
  1655.             DP      3
  1656.             B,D     2
  1657.             A,D     1
  1658.             CC      0
  1659.  
  1660.  
  1661. For the instructions EXG and TFR, exactly two of the above register
  1662. names must be included in the register list. The other restriction is
  1663. the size of the registers specified. For the EXG instruction, the two
  1664. registers must be the same size. For the TFR instruction, the two
  1665. registers must be the same size, or the first can be a 16-bit register
  1666. and the second an 8-bit register. In the case where the transfer is
  1667. from a 16-bit register to an 8-bit register, the least significant 8
  1668. bits are transferred.  The 8-bit registers are A, B, CC, and DP.  The
  1669. 16-bit registers are D, PC, S, U, X, and Y.  The one-byte immediate
  1670. value assigned to the operand by the assembler is determined by the
  1671. register names. The most significant four bits of the immediate byte
  1672. contain the value of the first register name; the least significant
  1673. four bits contain the value of the second register, as shown by the
  1674. following table:.
  1675.  
  1676.  
  1677.           Register  Value (hex)
  1678.           --------  -----------
  1679.  
  1680.              D          0
  1681.              X          1
  1682.              Y          2
  1683.              U          3
  1684.              S          4
  1685.              PC         5
  1686.              A          8
  1687.              B          9
  1688.              CC         A
  1689.              DP         B
  1690.  
  1691.  
  1692. RELATIVE  ADDRESSING
  1693. Relative addressing is used by branch instructions. There are two
  1694. forms of the branch instruction. The short branch can only be executed
  1695. within the range -126 to +129 bytes relative to the first byte of the
  1696. branch instruction. For this mode, the programmer specifies the branch
  1697. address expression and places it in the operand field. The actual
  1698. branch offset is calculated by the assembler and put into the second
  1699. byte of the branch instruction. The long branch can execute in the
  1700. full range of addressing from 0000-FFFF (hexadecimal) because a two-
  1701. byte offset is calculated by the assembler and put into the operand
  1702. field of the branch instruction.  The offset is the two's complement
  1703. of the difference between the location of the byte immediately 
  1704.  
  1705.  
  1706.                                 23
  1707.  
  1708.  
  1709.  
  1710.  
  1711.                                    Freeware Assemblers User's Manual
  1712.  
  1713.  
  1714. following the branch instruction and the location of the destination
  1715. of the branch.
  1716.  
  1717.  
  1718. DIRECT AND EXTENDED ADDRESSING
  1719. Direct and extended addressing utilize one (direct) or two (extended)
  1720. bytes to contain the address of the operand. Direct and extended
  1721. addressing are indicated by having only an expression in the operand
  1722. field (i.e., <expression>). Direct addressing will be used whenever
  1723. possible.
  1724.  
  1725. Regardless of the criteria described above, it is possible to force
  1726. the Assembler to use the direct addressing mode by preceding the
  1727. operand with the "<" character. Similarly, extended addressing can be
  1728. forced by preceding the operand with the ">" character.  These two
  1729. operand forms are: <<expression> and ><expression>.
  1730.  
  1731.  
  1732. INDEXED ADDRESSING
  1733. Indexed addressing is relative to one of the index registers. The
  1734. general form is <expression>,R. The address is calculated at the time
  1735. of instruction execution by adding the value of <expression> to the
  1736. current contents of the index register. The other general form is
  1737. [<expression>,R].   In this indirect form, the address is calculated
  1738. at the time of instruction execution by first adding the value of
  1739. <expression> to the current contents of the index register, and then
  1740. retrieving the two bytes from the calculated address and address+1.
  1741. This two-byte value is used as the effective address of the operand.
  1742. The allowable forms of indexed addressing are described below.  In the
  1743. description below, R refers to one of the index registers S, U, X, or
  1744. Y.
  1745.  
  1746. The accumulator offset mode allows one of the accumulators to be
  1747. specified instead of an <expression>. Valid forms are:.
  1748.  
  1749.                    <acc>,R and [<acc>,R]
  1750.  
  1751. where <acc>  is one of the accumulators A, B, or D. This form
  1752. generates a one-byte operand (post-byte only). When accumulator A or B
  1753. is specified, sign extension occurs prior to adding the value in the
  1754. accumulator to the index register.
  1755.  
  1756. The valid forms for the automatic increment/decrement mode are shown
  1757. below.  For each row, the three entries shown are equivalent.
  1758.  
  1759.  
  1760.                R+       ,R+      0,R+
  1761.                -R       ,-R      0,-R
  1762.                R++      ,R++     0,R++
  1763.                --R      ,--R     0,--R
  1764.                [R++]    ,R++]    [0,R++]
  1765.                [--R]    [,--R]   [0,--R]
  1766.  
  1767.  
  1768. In this form, the only valid expression is 0. Like the accumulator
  1769. offset mode, this form generates a one-byte operand (post-byte only).
  1770.  
  1771.  
  1772.                                 24
  1773.  
  1774.  
  1775.  
  1776.  
  1777.                                    Freeware Assemblers User's Manual
  1778.  
  1779.  
  1780. The valid forms for the expression offset mode are:
  1781.  
  1782.  
  1783.                R       ,R     <expression>,R
  1784.                [R]     [,R]   [<expression>,R]
  1785.                <R      <,R    <<expression>,R
  1786.                <[R]    <[,R]  <[<expression>,R]
  1787.                >R      >,R    ><expression>,R
  1788.                >[R]    >[,R]  >[<expression>,R]
  1789.  
  1790.  
  1791. The "<" and ">" characters force an 8- or 16-bit offset, respectively,
  1792. and are described below. If no expression is specified, or if an
  1793. expression with a value of zero is specified, only the postbyte of
  1794. the operand is generated. If an expression with a value in the range
  1795. -16 to +15 is specified without indirection, a one- byte operand is
  1796. generated which contains the expression's value, as well as the index
  1797. register indicator. At execution time, the expression's value is
  1798. expanded to 16 bits with sign extension before being added to the
  1799. index register.
  1800.  
  1801. All other forms will generate a post-byte, as well as either a one- or
  1802. two-byte offset which contains the value of the expression. The size
  1803. of the offset is determined by the type and size of the expression.
  1804. Expressions with values in the range -128 to +127 generate an 8-bit
  1805. offset.   All other cases will result in a 16-bit offset being
  1806. generated. In the case where an 8-bit offset is generated, the value
  1807. is expanded to 16 bits with sign extension at execution time.
  1808.  
  1809. Regardless of the criteria described above, it is possible to force
  1810. the Assembler to generate an 8-bit offset by preceding the operand
  1811. with the "<" character. Similarly, a 16-bit offset can be forced by
  1812. preceding the operand with the ">" character.
  1813.  
  1814. If the relative address calculated is not in the range -128 to +127,
  1815. or if the expression references a symbol that has not yet been
  1816. defined, a two-byte offset is generated after the post-byte. A one-
  1817. byte offset is generated if the relative address is in the range -128
  1818. to +127.
  1819.  
  1820. Like the expression offset mode, a one-byte offset can be forced by
  1821. preceding the operand with a "<".  A ">" forces a two-byte offset. A
  1822. byte overflow error is generated if a one-byte offset is forced when
  1823. the relative address is not in the range -12
  1824. 8 to +127.
  1825.  
  1826. The extended indirect mode has the form:
  1827.  
  1828.                      [<expression>]
  1829.  
  1830. Although extended indirect is a logical extension of the extended
  1831. addressing mode, this mode is implemented using an encoding of the
  1832. postbyte under the indexed addressing mode.  A post-byte and a two-
  1833. byte offset which contains the value of the expression is generated.
  1834.  
  1835.  
  1836.  
  1837.  
  1838.                                 25
  1839.  
  1840.  
  1841.  
  1842.  
  1843.                                    Freeware Assemblers User's Manual
  1844.  
  1845.  
  1846. B.5  M68HC11 ADDRESSING MODES.
  1847.  
  1848. PREBYTE
  1849. The number of combinations of instructions and addressing modes for
  1850. the 68HC11 is larger than that possible to be encoded in an 8-bit word
  1851. (256 combinations).  To expand the opcode map, certain opcodes ($18,
  1852. $1A, and $CD) cause the processor to fetch the next address to find
  1853. the actual instruction.  These opcodes are known as prebytes and are
  1854. inserted automatically by the assembler for those instructions that
  1855. require it.l  In general the instructions contained in the alternate
  1856. maps are those involving the Y register or addressing modes that
  1857. involve the Y index register.  Thus the programmer make the tradeoff
  1858. between the convenience of using the second index register and the
  1859. additional time and code space used by the prebyte.
  1860.  
  1861.  
  1862. INHERENT OR ACCUMULATOR ADDRESSING
  1863. The M68HC11 includes some instructions which require no operands.
  1864. These instructions are self-contained, and employ the inherent
  1865. addressing or the accumulator addressing mode.
  1866.  
  1867.  
  1868. IMMEDIATE ADDRESSING
  1869. Immediate addressing refers to the use of one or more bytes of
  1870. information that immediately follow the operation code in memory.
  1871. Immediate addressing is indicated by preceding the operand field with
  1872. the pound sign or number sign character (#). The expression following
  1873. the # will be assigned one byte of storage.
  1874.  
  1875.  
  1876. RELATIVE ADDRESSING
  1877. Relative addressing is used by branch instructions. Branches can only
  1878. be executed within the range -126 to +129 bytes relative to the first
  1879. byte of the branch instruction. For this mode, the programmer
  1880. specifies the branch address expression and places it in the operand
  1881. field. The actual branch offset is calculated by the assembler and put
  1882. into the second byte of the branch instruction.  The offset is the
  1883. two's complement of the difference between the location of the byte
  1884. immediately following the branch instruction and the location of the
  1885. destination of the branch.  Branches out of bounds are flagged as
  1886. errors by the assembler.
  1887.  
  1888.  
  1889. INDEXED ADDRESSING
  1890. Indexed addressing is relative one of the index registers X or Y.  The
  1891. address is calculated at the time of instruction execution by adding a
  1892. one-byte displacement to the current contents of the X register. The
  1893. displacement immediately follows the operation code in memory.  If the
  1894. displacement is zero, zero resides in the byte following the opcode.
  1895. Since no sign extension is performed on a one-byte displacement, the
  1896. offset cannot be negative. Indexed addressing is indicated by the
  1897. characters ",X" following the expression in the operand field.  The
  1898. special case of ",X", without a preceding expression, is treated as
  1899. "0,X".
  1900.  
  1901.  
  1902.  
  1903.  
  1904.                                 26
  1905.  
  1906.  
  1907.  
  1908.  
  1909.                                    Freeware Assemblers User's Manual
  1910.  
  1911.  
  1912. DIRECT AND EXTENDED ADDRESSING
  1913. Direct and extended addressing utilize one (direct) or two (extended)
  1914. bytes to contain the address of the operand. Direct addressing is
  1915. limited to the first 256 bytes of memory.  Direct and extended
  1916. addressing are indicated by only having an expression in the operand
  1917. field.  Direct addressing will be used by the Assembler whenever
  1918. possible.
  1919.  
  1920.  
  1921. BIT(S) SET OR CLEAR
  1922. The addressing mode used for this type of instruction is direct,
  1923. although the format of the operand field is different from the direct
  1924. addressing mode described above. The operand takes the form
  1925. <expression 1> <expression 2> where the two expressions are separated
  1926. by a blank.   <expression 1> signifies the operand address and may be
  1927. either a direct or an indexed address.  When the address mode is
  1928. indexed, <expression  1> is followed by ',R' where R is either X or Y.
  1929. This allows bit manipulation instructions to operate across the
  1930. complete 64K address map.  <expression 2> is the mask byte.  The
  1931. bit(s) to be set or cleared are indicated by ones in the corresponding
  1932. location(s) in the mask byte.  The mask byte must be an expression in
  1933. the range 0-255 and is encoded by the programmer.
  1934.  
  1935.  
  1936. BIT TEST AND BRANCH
  1937. This combines two addressing modes: direct or indexed and relative.
  1938. The format of the operand is: <expression 1> <expression 2>
  1939. <expression 3> where the expressions are separated by blanks.
  1940. <expression 1>  identifies the operand an may indicate either a direct
  1941. or indexed address.  Indexed addresses are signified with ',R'
  1942. following the expression where R is either X or Y. <expression 2> is
  1943. the mask byte.  The bit(s) to be set or cleared are indicated by ones
  1944. in the corresponding location(s) in the mask byte.  The mask byte must
  1945. be an expression in the range 0-255 and is encoded by the programmer.
  1946. <expression 3> is used to generate a relative address, as described
  1947. above in "relative addressing".
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.                                 27
  1971.  
  1972.  
  1973.  
  1974.  
  1975.                                    Freeware Assemblers User's Manual
  1976.  
  1977.  
  1978.                                APPENDIX C
  1979.                             DIRECTIVE SUMMARY
  1980.  
  1981.  
  1982. A complete description of all directives appears in Chapter 4.
  1983.  
  1984.  
  1985. ASSEMBLY CONTROL
  1986.  
  1987.      ORG  Origin program counter
  1988.  
  1989. SYMBOL DEFINITION
  1990.  
  1991.      EQU  Assign permanent value
  1992.  
  1993. DATA DEFINITION/STORAGE ALLOCATION
  1994.  
  1995.      BSZ  Block storage of zero; single bytes
  1996.  
  1997.      FCB  Form constant byte
  1998.  
  1999.      FCC  Form constant character string
  2000.  
  2001.      FDB  Form constant double byte
  2002.  
  2003.      FILL Initialize a block of memory to a constant
  2004.  
  2005.      RMB  Reserve memory; single bytes
  2006.  
  2007.      ZMB  Zero Memory Bytes; same and BSZ
  2008.  
  2009.  
  2010.  LISTING CONTROL
  2011.  
  2012.      OPT c     Enable cycle counting
  2013.  
  2014.      OPT cre   Print cross reference table
  2015.  
  2016.      OPT l     Print source listing from this point
  2017.  
  2018.      OPT nol   Inhibit printing of source listing from this point
  2019.  
  2020.      OPT s     Print symbol table
  2021.  
  2022.      PAGE Print subsequent statements on top of next page
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.                                 28
  2037.  
  2038.  
  2039.  
  2040.  
  2041.                                    Freeware Assemblers User's Manual
  2042.  
  2043.  
  2044.                               APPENDIX D
  2045.                         ASSEMBLER LISTING FORMAT
  2046.  
  2047.  
  2048. The Assembler listing has the following format:
  2049.  
  2050.     LINE#   ADDR  OBJECT CODE BYTES       [ # CYCLES]  SOURCE LINE
  2051.  
  2052. The LINE# is a 4 digit decimal number printed as a reference.  This
  2053. reference number is used in the cross reference.  The ADDR is the hex
  2054. value of the address for the first byte of the object code for this
  2055. instruction.   The OBJECT CODE BYTES are the assembled object code of
  2056. the source line in hex.  If an source line causes more than 6 bytes
  2057. to be output (e.g. a long FCC directive), additional bytes (up to 64)
  2058. are listed on succeeding lines with no address preceding them.
  2059.  
  2060. The # CYCLES will only appear in the listing if the "c" option is in
  2061. effect.  It is enclosed in brackets which helps distinguish it from
  2062. the source listing.  The SOURCE LINE is reprinted exactly from the
  2063. source program, including labels.
  2064.  
  2065. The symbol table has the following format:
  2066.  
  2067.      SYMBOL    ADDR
  2068.  
  2069. The symbol is taken directly from the label field in the source
  2070. program.  The ADDR is the hexadecimal address of the location
  2071. referenced by the symbol.
  2072.  
  2073. The cross reference listing has the following format:
  2074.  
  2075.      SYMBOL   ADDR   *LOC1 LOC2 LOC3 ...
  2076.  
  2077. The SYMBOL and ADDR are the same as above. The * indicates the start
  2078. of the line reference numbers.  The LOCs are the decimal line numbers
  2079. of the assembler listing where the label occurs.
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.                                 29
  2103.  
  2104.  
  2105.  
  2106.  
  2107.                                    Freeware Assemblers User's Manual
  2108.  
  2109.  
  2110.                               APPENDIX E
  2111.                          S-RECORD INFORMATION
  2112.  
  2113.  
  2114. E.1   INTRODUCTION
  2115.  
  2116. The S-record output format encodes program and data object modules
  2117. into a printable (ASCII) format.  This allows viewing of the object
  2118. file with standard tools and allows display of the module while
  2119. transferring from one computer to the next or during loads between a
  2120. host and target.  The S-record format also includes information for
  2121. use in error checking to insure the integrity of data transfers.
  2122.  
  2123.  
  2124. E.2   S-RECORD CONTENT
  2125.  
  2126. S-Records are character strings made of several fields which identify
  2127. the record type, record length, memory address, code/data, and
  2128. checksum.  Each byte of binary data is encoded as a 2-character
  2129. hexadecimal number:  the first character representing the high-order
  2130. 4 bits, and the second the low-order 4 bits of the byte.
  2131.  
  2132. The 5 fields which comprise an S-record are:
  2133.  
  2134.       TYPE  RECORD LENGTH   ADDRESS   CODE/DATA  CHECKSUM
  2135.  
  2136. The fields are defined as follows:
  2137.  
  2138.      FIELD      CHARACTERS                   CONTENTS
  2139.      -----      ----------                   --------
  2140.      Type           2          S-record type - S1, S9, etc.
  2141.  
  2142.      Record         2          The count of the character pairs in the
  2143.      length                    record, excluding the type and record
  2144.                                length.
  2145.  
  2146.      Address      4, 6,        The 2-, 3-, or 4-byte address at which
  2147.                   or 8         the data field is to be loaded into
  2148.                                memory.
  2149.  
  2150.      Code/data    0-2n         From 0 to n bytes of executable code,
  2151.                                memory loadable data, or descriptive
  2152.                                information.
  2153.  
  2154.      Checksum       2          The least significant byte of the one's
  2155.                                complement of the sum of the values
  2156.                                represented by the pairs of characters
  2157.                                making up the record length, address,
  2158.                                and the code/data fields.
  2159.  
  2160. Each record may be terminated with a CR/LF/NULL.
  2161.  
  2162.  
  2163. E.3   S-RECORD TYPES
  2164.  
  2165. Eight types of s-records have been defined to accommodate various
  2166.  
  2167.  
  2168.                                 30
  2169.  
  2170.  
  2171.  
  2172.  
  2173.                                    Freeware Assemblers User's Manual
  2174.  
  2175.  
  2176. encoding, transportation, and decoding needs.  The Freeware
  2177. assemblers use only two types, the S1 and S9:
  2178.  
  2179.      S1   A record containing code/data and the 2-byte
  2180.           address at which the code/data is to reside.
  2181.  
  2182.      S9   A termination record for a block of S1 records. The address
  2183.           field may optionally contain the 2-byte address of the
  2184.           instruction to which control is to be passed.  If not
  2185.           specified, the first entry point specifica
  2186.           tion encountered in the object module input will be used.
  2187.           There is no code/data field.
  2188.  
  2189. E.4   S-RECORD EXAMPLE
  2190.  
  2191. The following is a typical S-record module:
  2192.  
  2193.           S1130000285F245F2212226A000424290008237C2A
  2194.           S11300100002000800082629001853812341001813
  2195.           S113002041E900084E42234300182342000824A952
  2196.           S107003000144ED492
  2197.           S9030000FC
  2198.  
  2199. The module consists of four code/data records and an S9 termination
  2200. record.
  2201.  
  2202. The first S1 code/data record is explained as follows:
  2203.  
  2204.      S1   S-record type S1, indicating a code/data record to be
  2205.           loaded/verified at a 2-byte address.
  2206.  
  2207.      13   Hex 13 (decimal 19), indicating 19 character pairs,
  2208.           representing 19 bytes of  binary data, follow.
  2209.  
  2210.      00   Four-character 2-byte address field:  hex address 0000,
  2211.           indicates location where the following data is to be loaded.
  2212.  
  2213.      The next 16 character pairs are the ASCII bytes of the actual
  2214.      program code/data
  2215.  
  2216.      2A   Checksum of the first S1 record.
  2217.  
  2218. The second and third S1 code/data records each also contain $13
  2219. character pairs and are ended with checksums.  The fourth S1 code/data
  2220. record contains 7 character pairs.
  2221.  
  2222. The S9 termination record is explained as follows:
  2223.  
  2224.      S9   S-record type S9, indicating a termination record.
  2225.  
  2226.      03   Hex 03, indicating three character pairs (3 bytes) to
  2227.           follow.
  2228.  
  2229.      00   Four character 2-byte address field, zeroes.
  2230.      00
  2231.  
  2232.      FC   Checksum of  S9 record.
  2233.  
  2234.                                 31
  2235.  
  2236.  
  2237.                                                                                                           
  2238.